#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import *
import pygame
import random
from pygame.locals import *
from sys import exit
from gameobjects.vector2 import Vector2

from classes import *

def quit(event):
	pressed_keys = pygame.key.get_pressed()
	if pressed_keys[K_ESCAPE]:
		exit()

	event = pygame.event.poll()
	if event.type == QUIT:
		exit()

pygame.init()

screen = pygame.display.set_mode((800, 600), 0, 32)
pygame.display.set_caption("Critter Ball!")

zombie = Zombie("Bob")
enemy = [zombie]
player = Player("Critter")
bullets = []
bullet = Bullet("Bill")

while True:
	event = pygame.event.poll()

	quit(event)
	
	screen.fill((255, 255, 255))
	
	mouse_pos = pygame.mouse.get_pos()

	player.movement(enemy,bullets)
	player.shooting(event,bullets)
	bullet.animate(bullets,player)
	
	for count in range(0,len(bullets)):
		x = bullets[count].position
		x = (int(x[0]), int(x[1]))
		pygame.draw.circle(screen, (0,0,0), x, 2)


	pygame.draw.circle(screen, (255,0,0), (zombie.x,zombie.y), 10)
	pygame.draw.circle(screen, (0,255,0), (player.x,player.y), 10)
	pygame.draw.line(screen, (0, 0, 0), (player.x, player.y), mouse_pos)
	
	pygame.display.update()